#ifndef _CIRCLE_BUFFER_HPP_20120518
#define _CIRCLE_BUFFER_HPP_20120518

#include "base.hpp"
#include "circle_array.hpp"

namespace mina
{
	class CircleBuffer
	{
		public :
			CircleBuffer(int block_size, int block_num);
			~CircleBuffer();

			int block_size() const { return _block_size; }
			int free_block() const { return _circle_buffer.size();  }

			bool empty() const { return _circle_buffer.empty(); }
			bool full()  const { return _circle_buffer.full();  }

			char * allocate();
			void  deallocate(void * addr);

		public :
			int                 _block_size;
			CircleArray<char*>  _circle_buffer;

		private :
			char  *             _base;
			char  *             _end;

			DECL_LOGGER(logger);
	};
}

#endif

